let path = require('path');
let express = require('express');
let proxy = require("http-proxy-middleware");
function resolve(dir){
    return path.join(__dirname, dir)
}
function addStyleResource (rule) {
    rule.use('style-resource')
    .loader('style-resources-loader')
    .options({
        patterns: [
            path.resolve(__dirname, 'src/assets/varibles.styl')
        ]
    })
}
module.exports = {
    lintOnSave: false,
    devServer: {
			proxy: {
				'/apii': {
					target: 'http://172.25.110.40:8888',
					ws: true,
					changeOrigin: true,
					pathRewrite: {
						'^/apii': '', //代理的路径
					},
				},
                // '/zhanglulu': {
				// 	target: 'http://api.caiyunapp.com',
				// 	changeOrigin: true,
                //     pathRewrite: {
				// 		'^/zhanglulu': '', //代理的路径
				// 	},
				// },
			},
		},
    // 
	chainWebpack: config => {
        const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
        types.forEach(type => addStyleResource(config.module.rule('stylus').oneOf(type)))
        config.resolve.alias
            .set('pages', resolve('src/pages'))
            .set('common', resolve('src/common'))
            .set('components', resolve('src/components'))
    }
}
